package sqlanalysisgui.view.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class ProjectInfo {
	private static int counter = 0;
	private int id;	
	private String projectName;
	private String projectInfo;
	private String projectPath;
	private String projectRegDate;
	/*
	 * JFace Data Binding 은 자바오브젝트의 속성이 변했을 때 이를 감지하고 반응할 수 있도록 자기 자신을 이 속성의
	 * listener로 등록할 수 있다. SWT와 JFace Widget은 이것을 지원한다.
	 */
	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	public ProjectInfo() {
		// TODO Auto-generated constructor stub
	}

	public ProjectInfo(String projectName, String projectInfo,
			String projectPath, String projectRegDate) {
		super();
		id = counter++;
		this.projectName = projectName;
		this.projectInfo = projectInfo;
		this.projectPath = projectPath;
		this.projectRegDate = projectRegDate;
	}

	public static int getCounter() {
		return counter;
	}

	public static void setCounter(int counter) {
		ProjectInfo.counter = counter;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public void addPropertyChangeListener(String propertyName,
			PropertyChangeListener listener) {
		propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
	}

	public void removePropertyChangeListener(PropertyChangeListener listener) {
		propertyChangeSupport.removePropertyChangeListener(listener);
	}

	public String getProjectName() {
		return projectName;
	}

	public void setProjectName(String projectName) {
		propertyChangeSupport.firePropertyChange("projectName",
				this.projectName, this.projectName = projectName);
	}

	public String getProjectInfo() {
		return projectInfo;
	}

	public void setProjectInfo(String projectInfo) {
		propertyChangeSupport.firePropertyChange("projectInfo",
				this.projectInfo, this.projectInfo = projectInfo);
	}

	public String getProjectPath() {
		return projectPath;
	}

	public void setProjectPath(String projectPath) {
		propertyChangeSupport.firePropertyChange("projectPath",
				this.projectPath, this.projectPath = projectPath);
	}

	public String getProjectRegDate() {
		return projectRegDate;
	}

	public void setProjectRegDate(String projectRegDate) {
		propertyChangeSupport.firePropertyChange("projectRegDate",
				this.projectRegDate, this.projectRegDate = projectRegDate);
	}

	@Override
	public String toString() {
		return "ProjectInfo [id=" + id + ", projectName=" + projectName
				+ ", projectInfo=" + projectInfo + ", projectPath="
				+ projectPath + ", projectRegDate=" + projectRegDate + "]";
	}
	
	
}
